import { ref, reactive } from 'vue';

import {
  selectByPage as _selectByPage,
  insert as _insert,
  update as _update,
  detail as _detail,
  remove as _remove
} from '@/api/article'


export default function useArticle() {
  const list = ref([])
  const selectByPage = async () => {
    const { data } = await _selectByPage();
    list.value = data
  };
  const remove = async (id) => {
    const { data } = await _remove({ id })
    return data
  }
  const update = async (params) => {
    const { data } = await _update(params)
    return data
  }
  const insert = async (params) => {
    const { data } = await _insert(params)
    return data
  }
  const detail = async (id) => {
    const { data } = await _detail({ id })
    return data
  }

  return {
    list,
    selectByPage,
    remove,
    update,
    insert,
    detail
  }
}
